package com.fs.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

/**
 * @author yyds
 * @fileName House
 * @date 2024/9/10 15:37
 * @description
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("Houses")
public class House {
    @TableId
    private Integer hid;
    private String title;
    private Double money;
    private String room;
    private String phone;
    private Integer pid;
    private Integer sid;
    private Integer did;
    private Integer tid;
    private String info;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date time;
    private Integer status;
    @TableField(exist = false)
    private String shi;
    @TableField(exist = false)
    private String ting;
    @TableField(exist = false)
    private User user;
    @TableField(exist = false)
    private Districts districts;
    @TableField(exist = false)
    private Streets streets;
    @TableField(exist = false)
    private Htypes htypes;

    public String getRoom() {
        if (shi == null || ting == null) {
            return room;
        } else {
            room = shi + "室" + ting + "厅";
            return room;
        }
    }

    public String getShi() {
        return this.room.substring(0,1);
    }

    public String getTing() {
        return this.room.substring(2,3);
    }

    public Date getTime() {
        return new Date();
    }

}
